<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        li {
            list-style: none;
            width: 50px;
            height: 40px;
            border: 1px solid #ccc;
            line-height: 40px;
            text-align: center;
            float: left;
        }
    </style>
</head>

<body>
    <div id="box1"></div>
    <button>排序</button>
    <script>
        var oDiv = document.querySelector('#box1')
        var oBtn = document.querySelector('button')
        var arr = [3, 5, 7, 8, 4, , 9, 43]
        crli()
        function crli() {
            arr.map(ele => {
                var li = document.createElement('li')
                li.innerHTML = ele
                oDiv.appendChild(li)
            })
        }
        oBtn.onclick = function () {
            oDiv.innerHTML=''
            arr = arr.sort((a, b) => {
                return a - b
            })
            crli()
        }
    </script>
</body>

</html>